package v1ch06.interfaces;

import java.util.Arrays;
import java.util.Iterator;

/**
 * 该程序演示了Comparable接口的用法。
 *
 * @author Cay Horstmann
 * @version 1.30 2004-02-27
 */
public class EmployeeSortTest {
	public static void main(String[] args) {
		Employee[] staff = new Employee[3];
		
		staff[0] = new Employee("Harry Hacker", 35000);
		staff[1] = new Employee("Carl Cracker", 75000);
		staff[2] = new Employee("Tony Tester", 38000);
		
		Arrays.sort(staff);
		
		// 打印出有关所有Employee对象的信息
		for (Employee e : staff) {
			System.out.println("name=" + e.getName() + ",salary=" + e.getSalary());
		}
		
		Iterator<Employee> iter = Arrays.stream(staff).iterator();
		Employee e;
		while (iter.hasNext()) {
			e = iter.next();
			System.out.println("name1=" + e.getName() + ",salary1=" + e.getSalary());
		}
		
	}
}